﻿using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Xml.Serialization;
using Microsoft.WowAddonStudio.FrameXml.Serialization.TypeConverters;

namespace Microsoft.WowAddonStudio.FrameXml.Serialization
{
    [Serializable]
    [DesignerCategory("code")]
    [XmlType(AnonymousType = true, Namespace = "http://www.blizzard.com/wow/ui/")]
    [DebuggerDisplay("Left = {Left}, Top = {Top}, Right = {Right}, Bottom = {Bottom}")]
	[TypeConverter(typeof(TexCoordsTypeConverter))]
    public class TexCoords : ICloneable, ICopiable<TexCoords>
    {
		/// <summary>
		/// Initializes a new instance of the <see cref="TexCoords"/> class.
		/// </summary>
    	public TexCoords()
    	{
    	}

		/// <summary>
		/// Initializes a new instance of the <see cref="TexCoords"/> class.
		/// </summary>
		/// <param name="allCoords">All coords.</param>
		internal TexCoords(float allCoords)
		{
			Left = allCoords;
			Right = allCoords;
			Top = allCoords;
			Bottom = allCoords;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="TexCoords"/> class.
		/// </summary>
		/// <param name="left">The left.</param>
        /// <param name="top">The top.</param>
        /// <param name="right">The right.</param>
        /// <param name="bottom">The bottom.</param>
        internal TexCoords(float left, float top, float right,float bottom)
    	{
    		Left = left;
    		Right = right;
    		Top = top;
    		Bottom = bottom;
    	}

    	/// <summary>
        /// Gets or sets the left component of the texture coordinates.
        /// </summary>
        [XmlAttribute("left")]
		[NotifyParentProperty(true)]
		[Description("The left value of TexCoords.")]
        public float Left { get; set; }

        /// <summary>
        /// Gets or sets the right component of the texture coordinates.
        /// </summary>
        [XmlAttribute("right")]
		[Description("The right value of TexCoords.")]
		[NotifyParentProperty(true)]
        public float Right { get; set; }

        /// <summary>
        /// Gets or sets the top component of the texture coordinates.
        /// </summary>
        [XmlAttribute("top")]
		[NotifyParentProperty(true)]
		[Description("The top value of TexCoords.")]
        public float Top { get; set; }

        /// <summary>
        /// Gets or sets the bottom component of the texture coordinates.
        /// </summary>
        [XmlAttribute("bottom")]
		[NotifyParentProperty(true)]
		[Description("The bottom value of TexCoords.")]
        public float Bottom { get; set; }

        /// <summary>
        /// Creates a new object that is a copy of the instance.
        /// </summary>
        /// <returns>The copied instance.</returns>
        /// <remarks>Performs a deep copy.</remarks>
        public TexCoords Copy()
        {
            return new TexCoords(this.Left, this.Top, this.Right, this.Bottom);
        }

        /// <summary>
		/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </summary>
		/// <returns>
		/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </returns>
    	public override string ToString()
    	{
            return string.Format("TexCoords: [Left = {0}, Top = {1}, Right = {2}, Bottom = {3}]", Left, Top, Right, Bottom);
    	}

        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public object Clone()
        {
            return Copy();
        }
    }
}